import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect:'/login'
    },
    {
      path: '/login',
      name:'登录',
      meta:{title:'登录'},
      component:()=>import('@/views/login/index.vue')
    },
    {
      path: '/layout',
      name: '菜单',
      component: () => import('@/views/layout/index.vue'),
      children:[
         {
        path: '/home',
        name: '首页',
         meta:{title:'首页'},
        component: () => import('@/views/home/index.vue'),
        },
      {
      path: '/system',
      name: '系统概述',
      meta:{title:'系统概述'},
      component: () => import('@/views/system/index.vue'),
    },

    {
          path:'/user/product',
          name:'产品管理员',
          meta:{title:'产品管理员'},
          component:()=>import('@/views/user/product/index.vue')
    },
    {
          path:'/user/manage',
          name:'用户管理员',
                meta:{title:'用户管理员'},
          component:()=>import('@/views/user/manage/index.vue')
    },
    {
          path:'/user/message',
          name:'消息管理员',
                meta:{title:'消息管理员'},
          component:()=>import('@/views/user/message/index.vue')
    },
        {
          path:'/user/list',
          name:'用户列表',
                meta:{title:'用户列表'},
          component:()=>import('@/views/user/list/index.vue')
        },
    
 
        
        {
          path:'/product/in',
          name:'入库管理',
                meta:{title:'入库管理'},
          component:()=>import('@/views/product/in/index.vue')
        },
       {
          path:'/product/out',
          name:'出库管理',
                meta:{title:'出库管理'},
          component:()=>import('@/views/product/out/index.vue')
        },
    


    {
          path:'/message/list',
          name:'消息列表',
                meta:{title:'消息列表'},
          component:()=>import('@/views/message/manage/index.vue')
    },
    {
          path:'/message/back',
          name:'回收站',
              meta:{title:'回收站'},
          component:()=>import('@/views/message/back/index.vue')
    },
    

    {
      path:'/contrim',
      name:'合同管理',
            meta:{title:'合同管理'},
      component:()=>import('@/views/contrim/index.vue')
    },
    {
      path:'/operation',
      name:'操作日志',
            meta:{title:'操作日志'},
      component:()=>import('@/views/operation/index.vue')
    },
    {
      path:'/loginlogs',
      name:'登录日志',
            meta:{title:'登录日志'},
      component:()=>import('@/views/loginlogs/index.vue')
    },
    {
      path:'/setting',
      name:'系统设置',
            meta:{title:'系统设置'},
      component:()=>import('@/views/setting/index.vue')
    },
    {
      path:'/userinfo/avatar',
      name:'更换头像',
            meta:{title:'更换头像'},
      component:()=>import('@/views/userInfo/avatar/index.vue')
    },
        {
      path:'/userinfo/base',
      name:'基础信息设置',
            meta:{title:'基础信息设置'},
      component:()=>import('@/views/userInfo/baseInfo/index.vue')
    },
    {
      path:'/userinfo/password',
      name:'修改密码',
            meta:{title:'修改密码'},
      component:()=>import('@/views/userInfo/password/index.vue')
    },
    ]
    },
   
  ],
})


router.beforeEach((to:any, from:any, next:any) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})


export default router
